// ==UserScript==
// @name         Kill Baidu AD before search result
// @namespace    http://git.oschina.net/zivyuan/monkeyscript/blob/master/adremover/cleanBaiduSerach.js
// @version      0.1
// @description  Mark Baidu AD in search result flow
// @author       zivyuan
// @match        https://www.baidu.com/s*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    
    var filter_ad = function () {
        var clearCount = 0, markCount = 0,
            ads = $('#content_left a').each(function (){
            var a = $(this), node = a.parents('.c-container, [data-click], [data-pos]');
            if(a.text() == '广告'){
                node.css({'border':'1px solid #F00', 'dis--play':'none', 'opacity': '.2'}).addClass('cleared');
                clearCount ++;
            } else if(a.text() == '官网') {
                node.css({'border':'3px solid #1a62ae', "padding": "5px"}).addClass('cleared');
                markCount ++;
            }
        });
        
        return {clearCount:clearCount, markCount: markCount};
    };
    
    $(function (){
        var count = filter_ad();
        console.log('Baidu AD clear report ', count);
        
        $('#content_left>div').eq(0).insertBefore('<div class="hit_top_new">已隐藏 ' + count.clearCount + ' 条广告. <a class="showad" href="javascript:void(0)">点击恢复!</a></div>');
    });
})();